

#ifndef __COSTR_C__
#define __COSTR_C__

#include "typedef.h"
#include "costr.h"


void memory_clear(uint8* data, uint16 dlen) {
	while(dlen > 0U) {
		(*data) = (uint8)0U;
		data++;
		dlen--;
	}
}

void memory_copy(const uint8 *src, uint8* dst, uint16 len) {
	uint16 index = 0;
	for(index = 0; index < len; index++) {
		dst[index] = src[index];
	}
}

void memory_set(uint8 *data, uint8 value, uint16 len) {
	while(len > 0U) {
		(*data) = (uint8)value;
		data++;
		len--;
	}
}

bool memory_cmp(const uint8 *source, const uint8* target, uint16 size) {
	bool result = TRUE;
	uint16 index;
	for(index = 0U; index < size; index++) {
		if(source[index] != target[index]) {
			result = FALSE;
			break ;
		}
	}
	return result;
}

uint8 dec_to_hex_single(uint8 dec_number) {
	uint8 result = (dec_number >= 10U) ? (uint8)(dec_number - 10U + 'A') : (uint8)(dec_number + '0');
	return result;
}

void dec_to_hex(const uint8 *src, uint8 *dst, uint16 dlen) {
	uint16 index = 0;
	for(index = 0; index < dlen; index++) {
		dst[index] = dec_to_hex_single(src[index]);
	}
}



#endif /* __COSTR_C__ */
